#include "sw_input_manager.h"
#include <allegro5\allegro.h>

sw_input_manager::sw_input_manager() {
	_times_pressed = new int[ALLEGRO_KEY_MAX];
	_times_released = new int[ALLEGRO_KEY_MAX];
	_pressed = new bool[ALLEGRO_KEY_MAX];
	for (int i=0; i<ALLEGRO_KEY_MAX; i++) {
		_times_pressed[i] = 0;
		_times_released[i] = 0;
		_pressed[i] = false;
	}
}
sw_input_manager::~sw_input_manager() {
	delete[] _times_pressed;
	delete[] _times_released;
	delete[] _pressed;
}
void sw_input_manager::key_down(int key) {
	assert(!_pressed[key]);
	_pressed[key] = true;
	_times_pressed[key] ++;
}
void sw_input_manager::key_up(int key) {
	assert(_pressed[key]);
	_pressed[key] = false;
	_times_released[key] ++;
}
void sw_input_manager::mouse_moved(int x, int y) {
	_mouse_x = x;
	_mouse_y = y;
}
int sw_input_manager::mouse_x() {
	return _mouse_x;
}
int sw_input_manager::mouse_y() {
	return _mouse_y;
}
void sw_input_manager::reset_counts() {
	for (int i=0; i<ALLEGRO_KEY_MAX; i++) {
		_times_pressed[i] = 0;
		_times_released[i] = 0;
	}
}
int sw_input_manager::times_pressed(int key) {
	// TODO
	return _times_pressed[key];
}
int sw_input_manager::times_released(int key) {
	return _times_released[key];
}
bool sw_input_manager::pressed(int key) {
	return _pressed[key];
}